<%-- 
    Document   : list
    Created on : 2014-10-13, 14:59:05
    Author     : liuxulin
--%>
<%@page contentType="text/html; charset=UTF-8" session="false" %>
<%@include  file="/WEB-INF/jspf/import.jspf"%>
<style type="text/css">
    .medalDiv{
        float:left;
        margin-left: 20px;
    }
    .medalDiv *{
        line-height: 20px;
        display: block;
    }

    .medalType{
        margin-top: 20px;
        line-height: 25px;
    }
</style>
<div class="pageContent" style="height: 100%">
    <div style="float:left;">
        <b class="medalType">已经获得的勋章:</b>
        <div >
            <c:if test="${empty clubMedals}">
                暂无获取勋章
            </c:if>
            <c:forEach items="${clubMedals}" var = "o">
                <div class="medalDiv">
                    <img src="${o.url}" style="display: inline-block" width="34" height="34"/><span>${fn:escapeXml(o.name)}</span>
                    <input type="button" value="取消" onclick="cancelMedal(${o.medalId})"/>
                </div>
            </c:forEach>
        </div>
    </div>
    <div style="float:left;  clear: left;">
        <b class="medalType">未获得勋章:</b>
        <div>
            <c:if test="${empty medals}">
                已获得所有勋章
            </c:if>
            <c:forEach items="${medals}" var="m">
                <div class="medalDiv">
                    <img src="${m.url}"/>
                    <span>${fn:escapeXml(m.name)}</span>
                    <input type="button" value="颁发" onclick="issueMedal(${m.medalId})"/>
                </div> 
            </c:forEach>
        </div>
    </div>
</div>
<script type="text/javascript">
    function issueMedal(medalId){
        alertMsg.confirm("确定要颁发吗?",{
            okCall: function(){
                $.post("${ROOT}/admin/medal/issueMedal.do",{clubId:${clubId},medalId:medalId},function(data){
                    if(data.statusCode==200){
                        reloadDialog();
                    }
                },"json")
            },
            cancelCall : function() {}
        });
    }
    function cancelMedal(medalId){
        alertMsg.confirm("确定要取消吗?",{
            okCall: function(){
                $.post("${ROOT}/admin/medal/cancelMedal.do",{clubId:${clubId},medalId:medalId},function(data){
                    if(data  .statusCode==200){
                        reloadDialog();
                    }
                },"json");
            },
            cancelCall : function() {}
        });
       
    }
    function reloadDialog(){
        var dialog = $.pdialog.getCurrent();
        $.pdialog.reload(dialog.data("url"));
    }
</script>
